/**
 * Copyright (C) 2010 David Simonek <dafesimonek@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MergeSongsPanel.java
 *
 * Created on Sep 9, 2010, 1:09:13 PM
 */

package org.dafe.partyband.gui.songs;

import javax.swing.ButtonGroup;
import org.dafe.partyband.db.api.ISong;

/**
 *
 * @author dafe
 */
public class MergeSongsPanel extends javax.swing.JPanel {
    private final ISong song1;
    private final ISong song2;
    private final ButtonGroup bg;

    /** Creates new form MergeSongsPanel */
    public MergeSongsPanel(ISong song1, ISong song2) {
        initComponents();
        this.song1 = song1;
        this.song2 = song2;

        song1Radio.setText(song1.getName() + ", " + song1.getAuthor().getName());
        song2Radio.setText(song2.getName() + ", " + song2.getAuthor().getName());

        bg = new ButtonGroup();
        bg.add(song1Radio);
        bg.add(song2Radio);
    }

    public ISong getTargetSong () {
        return song1Radio.isSelected() ? song1 : song2;
    }

    public ISong getSourceSong () {
        return song1Radio.isSelected() ? song2 : song1;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jXLabel1 = new org.jdesktop.swingx.JXLabel();
        song2Radio = new javax.swing.JRadioButton();
        song1Radio = new javax.swing.JRadioButton();

        jXLabel1.setText(org.openide.util.NbBundle.getMessage(MergeSongsPanel.class, "MergeSongsPanel.jXLabel1.text",new Object[] {})); // NOI18N
        jXLabel1.setToolTipText(org.openide.util.NbBundle.getMessage(MergeSongsPanel.class, "MergeSongsPanel.jXLabel1.toolTipText",new Object[] {})); // NOI18N

        song2Radio.setText(org.openide.util.NbBundle.getMessage(MergeSongsPanel.class, "MergeSongsPanel.song2Radio.text",new Object[] {})); // NOI18N

        song1Radio.setSelected(true);
        song1Radio.setText(org.openide.util.NbBundle.getMessage(MergeSongsPanel.class, "MergeSongsPanel.song1Radio.text",new Object[] {})); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jXLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(song1Radio)
                            .addComponent(song2Radio))))
                .addContainerGap(105, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jXLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(song1Radio)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(song2Radio)
                .addContainerGap(42, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.jdesktop.swingx.JXLabel jXLabel1;
    private javax.swing.JRadioButton song1Radio;
    private javax.swing.JRadioButton song2Radio;
    // End of variables declaration//GEN-END:variables

}
